package com.qf.config;

import com.qf.Constant.RabbitMqConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.ManagedBean;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 你的名字
 * @Date: 2021/07/12/20:27
 * @Description:
 */
@Configuration
public class RbbitMqConfig  {
    //创建交换机
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(RabbitMqConstant.SHOP_EXCHANGE,true,false);
    }


    //创建队列
    @Bean
    public Queue goodsEsQueue() {
        return new Queue(RabbitMqConstant.GOOD_ES_QUEUE, true, false, false);
    }
    //队列绑定
    @Bean
    public Binding queueBindExchange(){
        return BindingBuilder.bind(goodsEsQueue()).to(topicExchange()).with("shop.*");
    }
}
